package com.chen.test;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextArea;

import com.chen.Shell;
import com.chen.gui.component.button.CButton;
import com.chen.gui.layout.SplitLayout;
import com.chen.gui.layout.TableLayout;
import com.chen.gui.window.ContentPane;
import com.chen.qq.Context;

/**
 * @author 5
 * 
 */
public class TalkPane extends ContentPane2 {

    private static final long serialVersionUID = 3302137739451167062L;

    private JButton btnImg = Context.getButton("0.png");

    private CButton btnRegister = Context.getButton("Chen", null);

    private JButton btnZone = Context.getButton("zone.png");

    private CButton btnVideo = Context.getButton("camera.png");
    private CButton btnAudio = Context.getButton("micro.png");
    private CButton btnFile = Context.getButton("file.png");
    private CButton btnDiscuss = Context.getButton("discuss.png");
    private CButton btnRemote = Context.getButton("remote.png");
    private CButton btnApply = Context.getButton("apply.png");

    private CButton btnAdv = Context.getButton("adv.png");
    private CButton btnShowOther = Context.getButton("showOther.png");
    private CButton btnShowMe = Context.getButton("showMe.png");

    private CButton btnFont = Context.getButton("font.png");
    private CButton btnExp = Context.getButton("exp.png");
    private CButton btnVipExp = Context.getButton("vipExp.png");
    private CButton btnShake = Context.getButton("shake.png");
    private CButton btnVoice = Context.getButton("voice.png");
    private CButton btnInput = Context.getButton("input.png");
    private CButton btnSendPic = Context.getButton("sendPic.png");
    private CButton btnSong = Context.getButton("song.png");
    private CButton btnScreenshot = Context.getButton("screenshot.png");
    private CButton btnRecord = Context.getButton("record.png");

    private JPanel centerPane = new JPanel(new SplitLayout());

    private JTextArea taTop = new JTextArea();
    private JTextArea taBottom = new JTextArea();

    public TalkPane() {
        super(ContentPane.CLOSE | ContentPane.MAX | ContentPane.MIN | ContentPane.SET);

        btnVideo.setMode(CButton.PopupMode);
        btnAudio.setMode(CButton.PopupMode);
        btnFile.setMode(CButton.PopupMode);
        btnDiscuss.setMode(CButton.PopupMode);
        btnRemote.setMode(CButton.PopupMode);
        btnApply.setMode(CButton.PopupMode);

        initLayout();
    }

    private void initLayout() {
        initTopPane();
        initCenterPane();
    }

    private void initTopPane() {
        translate(6, 8);
        add(btnImg);
        btnRegister.setMode(CButton.HyperLink);
        btnRegister.setForeground(Color.white);
        add(btnRegister);
        translate(5, 3);
        add(btnZone, btnRegister);

        translate(0, 5);
        add(btnVideo, btnImg);
        add(btnAudio);
        add(btnFile);
        add(btnDiscuss);
        add(btnRemote);
        add(btnApply);

        translateRight(5, 15);
        addRight(btnAdv, btnClose);
    }

    private void initCenterPane() {
        JPanel rootPane = Context.getBorderPane(centerPane);
        centerPane.add(taTop, SplitLayout.TOP);
        centerPane.add(taBottom, SplitLayout.BOTTOM);
        centerPane.add(btnFont);
        centerPane.add(btnExp);
        centerPane.add(btnVipExp);
        centerPane.add(btnShake);
        centerPane.add(btnVoice);
        centerPane.add(btnInput);
        centerPane.add(new JSeparator());
        centerPane.add(btnSendPic);
        centerPane.add(btnSong);
        centerPane.add(btnScreenshot);
        centerPane.add(btnRecord);

        double[][] para = { { TableLayout.PREFERRED },
                { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED } };
        JPanel panel = new JPanel(new TableLayout(para));
        panel.setOpaque(true);
        panel.add(btnShowOther, "0,0,f,f");
        panel.add(btnShowMe, "0,2,f,f");

        rootPane.add(panel, BorderLayout.EAST);

        translate(-5, 0);
        add(rootPane, btnVideo, Fill, Fill);
    }

    public static void main(String[] args) {
        TalkPane talkpane = new TalkPane();
        talkpane.setTitle("Hello");
        Shell.run(talkpane);
    }
}
